﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;

namespace Phoenix.Xna.Framework.Graphics
{
    public class TechniqueCollection : List<Technique>
    {
        private Effect _effect;

        public Effect Effect
        {
            get { return _effect; }
            set
            {
                _effect = value;

                foreach (Technique t in this)
                {
                    t.Effect = _effect;
                }
            }
        }

        public Technique this[string name]
        {
            get
            {
                foreach (Technique t in this)
                {
                    if (string.Compare(t.Name, name, true) == 0)
                    {
                        return t;
                    }
                }

                return null;
            }
            set
            {
                for (int i = 0; i < this.Count; i++)
                {
                    if (string.Compare(this[i].Name, name, true) == 0)
                    {
                        this[i] = value;
                        return;
                    }
                }

                // TODO : add exception message
                throw new IndexOutOfRangeException();
            }
        }

        public void LoadContent()
        {
            foreach (Technique t in this)
            {
                t.LoadContent();
            }
        }
    }
}
